//
//  MCHomeWageContractHeaderView.m
//  TLYL
//
//  Created by MC on 2017/11/8.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCHomeWageContractHeaderView.h"
#import "MCContractMgtTool.h"

@interface MCHomeWageContractHeaderView()

//DayWageStandard    String    日结标准（文本显示）
@property (nonatomic,strong) UILabel * DayWagesProportion ;//日结标准（数据）

@property (nonatomic,strong) UILabel *lab1;

@end
@implementation MCHomeWageContractHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    
    self.backgroundColor = [UIColor clearColor];
    
    UIView *baseView = [[UIView alloc] init];
    [self addSubview:baseView];
    baseView.backgroundColor = [UIColor whiteColor];
    //    baseView.frame=CGRectMake(0, 15, G_SCREENWIDTH-26, 94);
    baseView.frame=CGRectMake(0, 15, G_SCREENWIDTH-26, 48);
    baseView.clipsToBounds=YES;
    baseView.layer.cornerRadius=6;
    
    
    UILabel *lab1 = [[UILabel alloc] init];
    [baseView addSubview:lab1];
    lab1.text = @"我的日结契约";
    lab1.frame=CGRectMake(20, 15, 300, 18);
    lab1.font=[UIFont systemFontOfSize:12];
    lab1.textColor =RGB(46,46,46);
    _lab1 = lab1;
    
    UIButton *dayWageRuleBtn = [[UIButton alloc]init];
    [baseView addSubview:dayWageRuleBtn];
    [dayWageRuleBtn setTitle:@"日结规则" forState:UIControlStateNormal];
    [dayWageRuleBtn setTitleColor:RGB(255,109,154) forState:UIControlStateNormal];
    dayWageRuleBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    dayWageRuleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [dayWageRuleBtn addTarget:self action:@selector(popDayWageRule) forControlEvents:UIControlEventTouchUpInside];
    [dayWageRuleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(30);
        make.centerY.equalTo(lab1.mas_centerY);
        make.right.equalTo(baseView.mas_right).offset(-15);
        make.width.mas_equalTo(70);
    }];
    
    
    //    UIView *baseView2 = [[UIView alloc] init];
    //    [baseView addSubview:baseView2];
    //    baseView2.backgroundColor = RGB(246,243,248);
    //    baseView2.frame=CGRectMake(20, 43, G_SCREENWIDTH-60, 41);
    //    baseView2.layer.cornerRadius =5;
    //    baseView2.clipsToBounds=YES;
    //    CGFloat padding =18;
    //    if (G_SCREENWIDTH < 370) {
    //        padding = 5;
    //    }
    //
    //    //日结标准：1.1%        0        ：0
    //    _DayWagesProportion = [[UILabel alloc] init];
    //    _DayWagesProportion.font=[UIFont systemFontOfSize:12];
    //    _DayWagesProportion.textColor=RGB(249,84,83);
    //    _DayWagesProportion.textAlignment=NSTextAlignmentLeft;
    //    [baseView2 addSubview:self.DayWagesProportion];
    //    //    _DayWagesProportion.text = @"日结标准：--";
    //    _DayWagesProportion.text = @"加载中...";
    //    _DayWagesProportion.numberOfLines=0;
    //    [_DayWagesProportion mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.top.bottom.equalTo(baseView2);
    //        make.left.equalTo(baseView2.mas_left).offset(padding);
    //        //        make.width.mas_equalTo(150);
    //        make.right.equalTo(baseView2.mas_right).offset(-padding);
    //    }];
    
    
    
    
}


- (void)setDataSource:(MCGetMyDaywagesNewDataModel *)dataSource{
    _dataSource = dataSource;
    
    if (dataSource.DwRuleList.count>0) {
        
        MCGetMyDaywagesNewDwRuleListDataModel * model =[dataSource.DwRuleList lastObject];
        
        
        //        NSString * A =[NSString stringWithFormat:@"日结标准：%@",model.DayWageStandard];
        //        NSString * B =[NSString stringWithFormat:@"%@：%@",dataSource.GrantRemark,model.DaySales];
        //        NSString * C =[NSString stringWithFormat:@"活跃人数：%@",model.ActiveNumber];
        //
        //        _DayWagesProportion.text=[NSString stringWithFormat:@"%@\n%@  %@",A,B,C];
        
//        NSString * DayWagesProportion = [NSString stringWithFormat:@"%@",model.DayWagesProportion];
//        DayWagesProportion=GetRealFloatNum([DayWagesProportion doubleValue]*100);
        NSString * A =[NSString stringWithFormat:@"%@",model.DayWageStandard];
        if (A.length<1) {
            _lab1.text = @"我的日结契约:无";
        }else{
            _lab1.text = [NSString stringWithFormat:@"我的日结契约:%@",model.DayWageStandard];
        }
    }
}

+(CGFloat)computeHeight:(id)info{
    return 48+10+15;
}

#pragma mark-popDayWageRule
-(void)popDayWageRule{
    if (self.dayWageRuleBlock) {
        self.dayWageRuleBlock();
    }
}



/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end




















